import 'package:flutter/material.dart';
import 'package:plugins/plugins/DioExample.dart';
import 'package:plugins/plugins/video_player.dart';

import 'flutter_screenutil/flutter_screenutil.dart';

void main() {
  runApp(MyApp());
}

class DataModel {
  final String name;
  final String tag;
  DataModel(this.name, this.tag);
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  // 添加需要展示的 Widget 页面
  final Map<String, WidgetBuilder> routers = {
    '/FlutterScreenutil': (_) => FlutterScreenutil(),
    '/video_player': (_) => VideoPlayer(),
    '/dio': (_) => DioExample(),
  };

  List<DataModel> list = new List();
  @override
  void initState() {
    routers.forEach((key, value) {
      list.add(DataModel(key.substring(1), key));
    });
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Plugins Demo',
      routes: routers,
      home: Builder(
        builder: (BuildContext context) => Scaffold(
          appBar: AppBar(
            title: Text("Plugins Demo"),
          ),
          body: ListView.builder(
              itemCount: list.length,
              itemBuilder: (_, index) {
                return ListTile(
                  title: Text(list[index].name),
                  onTap: () => Navigator.pushNamed(context, list[index].tag),
                );
              }),
        ),
      ),
    );
  }

  void push(DataModel mode) {}
}
